package priv.dajie.tzzq.common;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSourceFactory;
import org.apache.ibatis.datasource.unpooled.UnpooledDataSourceFactory;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ClassName DruidDataSourceFactory
 * @Description
 * @Author dajie
 * @Date 2019/10/15 2:31 上午
 * @Version V1.0
 **/
public class DruidDataSourceFactory extends UnpooledDataSourceFactory {

    public DruidDataSourceFactory(){
//        Properties properties = new Properties();
//        InputStream inputStream = null;
//        try {
//            inputStream = new FileInputStream(System.getProperty("user.dir")+ "/config/db.properties");
//            properties.load(inputStream);
//            this.dataSource = com.alibaba.druid.pool.DruidDataSourceFactory.createDataSource(properties);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }finally {
//            if(inputStream!=null) {
//                try {
//                    inputStream.close();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
        this.dataSource = new DruidDataSource();
    }
}
